1 Mapping the Local Authority

1.1 Mapping Domestic Electricity Consumption

inFile <-paste0(dataFolder, "energy/Subnational_electricity_consumption_statistics_2019.csv")
la_elecData <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double(),
##   Region = col_character(),
##   `Local Authority` = col_character(),
##   `LA Code` = col_character(),
##   LAU1 = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
summary(la_elecData)
##     Region          Local Authority      LA Code              LAU1          
##  Length:385         Length:385         Length:385         Length:385        
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##                                                                             
##    E7_meters        Standard_meters     All_domestic_meters
##  Min.   :   0.158   Min.   :    0.714   Min.   :    1.176  
##  1st Qu.:   5.242   1st Qu.:   37.416   1st Qu.:   45.499  
##  Median :   8.810   Median :   52.081   Median :   62.364  
##  Mean   :  39.703   Mean   :  247.437   Mean   :  287.140  
##  3rd Qu.:  14.313   3rd Qu.:   91.393   3rd Qu.:  104.291  
##  Max.   :3942.609   Max.   :24769.164   Max.   :28711.773  
##                                                            
##  All_Non-domestic_meters  Total_meters           E7_GWh         
##  Min.   :   0.509        Min.   :    1.685   Min.   :    0.763  
##  1st Qu.:   3.827        1st Qu.:   49.377   1st Qu.:   27.992  
##  Median :   5.670        Median :   69.070   Median :   47.240  
##  Mean   :  25.636        Mean   :  312.776   Mean   :  200.460  
##  3rd Qu.:   8.569        3rd Qu.:  112.558   3rd Qu.:   71.991  
##  Max.   :2562.836        Max.   :31274.609   Max.   :19893.136  
##                                                                 
##   Standard_GWh      All_domestic_GWh    All_non-domestic_GWh
##  Min.   :    4.07   Min.   :     7.88   Min.   :     9.2    
##  1st Qu.:  127.31   1st Qu.:   169.40   1st Qu.:   240.1    
##  Median :  184.65   Median :   238.49   Median :   349.4    
##  Mean   :  829.09   Mean   :  1029.55   Mean   :  1691.9    
##  3rd Qu.:  294.38   3rd Qu.:   348.68   3rd Qu.:   572.4    
##  Max.   :82843.63   Max.   :102736.77   Max.   :169804.1    
##                                                             
##    Total_GWh          E7_Mean_kWh   E7_Mediann_kWh Standard_Mean_kWh
##  Min.   :    17.09   Min.   :3039   Min.   :2088   Min.   :2655     
##  1st Qu.:   426.14   1st Qu.:4620   1st Qu.:3456   1st Qu.:3168     
##  Median :   582.30   Median :5056   Median :3962   Median :3379     
##  Mean   :  2721.46   Mean   :5188   Mean   :4036   Mean   :3426     
##  3rd Qu.:   928.49   3rd Qu.:5668   3rd Qu.:4467   3rd Qu.:3648     
##  Max.   :272540.85   Max.   :8245   Max.   :7647   Max.   :5706     
##                                                                     
##  Standard_Median_kWh Domestic_Mean_kWh Domestic_Median_kWh
##  Min.   :2096        Min.   :2756      Min.   :2158       
##  1st Qu.:2650        1st Qu.:3311      1st Qu.:2703       
##  Median :2774        Median :3598      Median :2887       
##  Mean   :2785        Mean   :3675      Mean   :2899       
##  3rd Qu.:2925        3rd Qu.:3992      3rd Qu.:3058       
##  Max.   :4553        Max.   :6704      Max.   :5493       
##                                                           
##  Non-domestic_Mean_kWh Non-domestic_Median_kWh Total_Mean_kWh  
##  Min.   : 18082        Min.   : 3317           Min.   :  4868  
##  1st Qu.: 49493        1st Qu.: 6662           1st Qu.:  7382  
##  Median : 63188        Median : 7570           Median :  8394  
##  Mean   : 69010        Mean   : 7521           Mean   :  9503  
##  3rd Qu.: 77634        3rd Qu.: 8386           3rd Qu.:  9379  
##  Max.   :297305        Max.   :19957           Max.   :148254  
##                                                                
##  Total_Median_kWh Average_household_mean_kWh
##  Min.   :2224     Min.   :2872              
##  1st Qu.:2774     1st Qu.:3477              
##  Median :2963     Median :3744              
##  Mean   :2983     Mean   :3901              
##  3rd Qu.:3146     3rd Qu.:4190              
##  Max.   :5614     Max.   :9127              
##                   NA's   :3
# geo_query <- "https://ons-inspire.esriuk.com/arcgis/rest/services/Administrative_Boundaries/Local_Authority_Districts_December_2018_Boundaries_UK_BGC/MapServer/0/query?where=lad18nm%20IN%20(%27Southampton%27,%27Portsmouth%27,%27Winchester%27,%27Eastleigh%27,%27Isle%20of%20Wight%27,%27Fareham%27,%27Gosport%27,%27Test%20Valley%27,%27East%20Hampshire%27,%27Havant%27,%27New%20Forest%27,%27Hart%27,%27Basingstoke%20and%20Deane%27)&outFields=lad18cd,lad18nm,long,lat&outSR=4326&f=geojson"
# #This only includes the ones we are interested in i.e the Solent
# message("Loading LA geometry from ONS Open Geography API") #Specifying the location message
# la_sf_data <- sf::st_read(geo_query)

# The above is very clever but it takes time
# Load from file
la_shpFile <- paste0(dataFolder, "/boundaries/LA/la_solent.shp")
la_sf_data <- sf::st_read(la_shpFile)
## Reading layer `la_solent' from data source 
##   `/Users/ben/University of Southampton/HCC Energy Landscape Mapping project - Documents/General/data/boundaries/LA/la_solent.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 13 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -1.957224 ymin: 50.57491 xmax: -0.7446835 ymax: 51.38392
## Geodetic CRS:  WGS 84
head(la_sf_data)
## Simple feature collection with 6 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -1.586543 ymin: 50.57491 xmax: -0.9747962 ymax: 51.38392
## Geodetic CRS:  WGS 84
##     lad18cd               lad18nm     long     lat
## 1 E06000044            Portsmouth -1.07023 50.8080
## 2 E06000045           Southampton -1.40025 50.9204
## 3 E06000046         Isle of Wight -1.33360 50.6713
## 4 E07000087               Fareham -1.23742 50.8539
## 5 E07000088               Gosport -1.16725 50.8064
## 6 E07000084 Basingstoke and Deane -1.22021 51.2594
##                         geometry
## 1 MULTIPOLYGON (((-1.071333 5...
## 2 MULTIPOLYGON (((-1.401357 5...
## 3 MULTIPOLYGON (((-1.301876 5...
## 4 MULTIPOLYGON (((-1.269333 5...
## 5 MULTIPOLYGON (((-1.113141 5...
## 6 MULTIPOLYGON (((-0.9861238 ...
la_elecData$lad18cd <- la_elecData$`LA Code`#Creating a variable with the local authority code in the same name of the consumption data
la_merged_sf <- merge(la_sf_data, la_elecData)#Merge the local Authority boundaries and the consumption data
ggplot2::ggplot(la_merged_sf) +
  geom_sf(aes(fill = Total_GWh))+scale_fill_gradient(low="green",high="red")

1.2 Mapping Transport

1.2.0.1 Freight

inFile <-paste0(dataFolder, "energy/Local Authority level Transport data.csv")
la_Transport <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   Code = col_character(),
##   Name = col_character(),
##   Personal = col_number(),
##   Freight = col_number(),
##   Total = col_number()
## )
summary(la_Transport)
##      Code               Name              Personal           Freight        
##  Length:416         Length:416         Min.   :      73   Min.   :      70  
##  Class :character   Class :character   1st Qu.:   39430   1st Qu.:   18565  
##  Mode  :character   Mode  :character   Median :   62636   Median :   30524  
##                                        Mean   :  316517   Mean   :  173070  
##                                        3rd Qu.:   87103   3rd Qu.:   51128  
##                                        Max.   :25370982   Max.   :13836237  
##                                        NA's   :18         NA's   :18        
##      Total         
##  Min.   :     143  
##  1st Qu.:   58748  
##  Median :   93167  
##  Mean   :  489587  
##  3rd Qu.:  139921  
##  Max.   :39207219  
##  NA's   :18
head(la_Transport)
## # A tibble: 6 x 5
##   Code      Name            Personal Freight  Total
##   <chr>     <chr>              <dbl>   <dbl>  <dbl>
## 1 W06000019 Blaenau Gwent      18254    7628  25882
## 2 W06000013 Bridgend           65194   30368  95562
## 3 W06000018 Caerphilly         56176   22264  78440
## 4 W06000015 Cardiff           155838   58791 214629
## 5 W06000010 Carmarthenshire    84616   51129 135744
## 6 W06000008 Ceredigion         31141   18534  49675
la_Transport$lad18cd <- la_Transport$Code # Creating a variable with the local authority code in the same name of the consumption data
la_merged_Transp <- merge(la_sf_data, la_Transport)# Merge the local Authority boundaries and the Transport data
ggplot2::ggplot(la_merged_Transp) +
  geom_sf(aes(fill = Freight)) +
  scale_fill_gradient(name = "Freight: Thousand tonnes of oil equivalent (ktoe)", low="green",high="red")

1.2.0.2 Personal

Note: this data is not per household/person so it will correlate (to some extent) with population size.

# re-use the merged dataset
ggplot2::ggplot(la_merged_Transp) +
  geom_sf(aes(fill = Personal)) +
  scale_fill_gradient(name = "Personal: Thousand tonnes of oil equivalent (ktoe)", low="green",high="red") 

## Mapping Fuel Poverty ### 2021 Proportion of Population

inFile<-paste0(dataFolder, "Fuel Poverty/2021 LA_Fuel_Poverty.csv")
la_fuelpov_2021<-readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Area Codes` = col_character(),
##   `Number of households1` = col_number(),
##   `Number of households in fuel poverty1` = col_number(),
##   `Proportion of households fuel poor (%)` = col_character()
## )
head(la_fuelpov_2021)
## # A tibble: 6 x 4
##   `Area Codes` `Number of househ… `Number of households … `Proportion of househ…
##   <chr>                     <dbl>                   <dbl> <chr>                 
## 1 E92000001              23661751                 3175979 13.40                 
## 2 E12000001               1191912                  176869 14.80                 
## 3 E06000047                235959                   36620 15.50                 
## 4 E06000005                 49204                    6881 14.00                 
## 5 E06000001                 42645                    6292 14.80                 
## 6 E06000002                 60318                    9966 16.50
la_fuelpov_2021$lad18cd <- la_fuelpov_2021$`Area Codes` # Creating a variable with the local authority code in the same name 
la_merged_Fuelpov2021 <- merge(la_sf_data, la_fuelpov_2021)# Merge the local Authority boundaries and the Fuel Poverty data
la_merged_Fuelpov2021$pcFP <- as.numeric(la_merged_Fuelpov2021$`Proportion of households fuel poor (%)`) # convert to numeric from char - why does it load as char??
ggplot2::ggplot(la_merged_Fuelpov2021) +
  geom_sf(aes(fill = pcFP)) +
  scale_fill_gradient(name = "Proportion of households fuel poor (%)", low="green",high="red")

2 Mapping the Middle Layer Super Output Areas (MSOA)

2.1 Mapping Domestic

2.1.1 Mapping the Electricity Consumption

# electricity consumption data at MSOA level (pre downloaded)
inFile <-paste0(dataFolder, "energy/MSOA_DOM_ELEC_2019.csv")
msoa_elecData <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `MSOA Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `Number of meters` = col_double(),
##   `Consumption (kWh)` = col_double(),
##   `Mean consumption (kWh per meter)` = col_double(),
##   `Median consumption (kWh per meter)` = col_double()
## )
head(msoa_elecData)
## # A tibble: 6 x 8
##   `Local Authority N… `Local Authority … `MSOA Name`  `Middle Layer Super Outpu…
##   <chr>               <chr>              <chr>        <chr>                     
## 1 Hartlepool          E06000001          Hartlepool … E02002483                 
## 2 Hartlepool          E06000001          Hartlepool … E02002484                 
## 3 Hartlepool          E06000001          Hartlepool … E02002485                 
## 4 Hartlepool          E06000001          Hartlepool … E02002487                 
## 5 Hartlepool          E06000001          Hartlepool … E02002488                 
## 6 Hartlepool          E06000001          Hartlepool … E02002489                 
## # … with 4 more variables: Number of meters <dbl>, Consumption (kWh) <dbl>,
## #   Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>
inf <-paste0(dataFolder, "boundaries/MSOA/msoa_solent.shp")
message("Loading Middle Layer Super Output Area (MSOA) from file")
## Loading Middle Layer Super Output Area (MSOA) from file
#When using shp files you might also need to have other supplementary files in the same folder to allow it to run https://cfss.uchicago.edu/notes/simple-features/
msoa_sf_data <- sf::read_sf(inf) 
head (msoa_sf_data)
## Simple feature collection with 6 features and 13 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 458985.4 ymin: 102894 xmax: 467725.4 ymax: 107035
## Projected CRS: OSGB 1936 / British National Grid
## # A tibble: 6 x 14
##   MSOA11CD  MSOA11NM    OBJECTID  BNG_E  BNG_N LONG_   LAT Shape_Leng Shape__Are
##   <chr>     <chr>          <int>  <int>  <int> <dbl> <dbl>      <dbl>      <dbl>
## 1 E02003524 Portsmouth…     3510 463726 106331 -1.10  50.9      8175.   1880016.
## 2 E02003525 Portsmouth…     3511 465172 105904 -1.08  50.8     13220.   2012966.
## 3 E02003526 Portsmouth…     3512 466581 106095 -1.06  50.9     10425.   2260228.
## 4 E02003527 Portsmouth…     3513 464176 104420 -1.09  50.8     21957.   3838768.
## 5 E02003529 Portsmouth…     3514 466420 104925 -1.06  50.8     10636.   1499618.
## 6 E02003530 Portsmouth…     3515 465411 103721 -1.07  50.8     13264.   1695461.
## # … with 5 more variables: Shape__Len <dbl>, LAD11CD <chr>, LAD11NM <chr>,
## #   nOAs <int>, geometry <MULTIPOLYGON [m]>
table(msoa_sf_data$LAD11NM)#how many MSOAs are in each LA
## 
## Basingstoke and Deane        East Hampshire             Eastleigh 
##                    22                    15                    15 
##               Fareham               Gosport                  Hart 
##                    14                    10                    11 
##                Havant         Isle of Wight            New Forest 
##                    17                    18                    23 
##            Portsmouth           Southampton           Test Valley 
##                    25                    32                    15 
##            Winchester 
##                    14
msoa_elecData$MSOA11CD <- msoa_elecData$ 'Middle Layer Super Output Area (MSOA) Code' #Creating a variable with the LA code and the name as in the sf_data
msoa_merged_sf <-merge(msoa_sf_data, msoa_elecData)
ggplot2::ggplot(msoa_merged_sf) + 
  geom_sf(aes(fill = `Mean consumption (kWh per meter)`)) +
  scale_fill_continuous(name = "Electricity: Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all MSOAs)")

#mapping it

2.1.2 Mapping the Gas

# gas consumption data at MSOA level (pre downloaded)
inFile <-paste0(dataFolder, "energy/MSOA_GAS_2019.csv")
msoa_gasData <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `MSOA Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `Number of consuming meters` = col_double(),
##   `Consumption (kWh)` = col_double(),
##   `Mean consumption (kWh per meter)` = col_double(),
##   `Median consumption (kWh per meter)` = col_double(),
##   `Number of non consuming meters` = col_character()
## )
head(msoa_gasData)
## # A tibble: 6 x 9
##   `Local Authority N… `Local Authority … `MSOA Name`  `Middle Layer Super Outpu…
##   <chr>               <chr>              <chr>        <chr>                     
## 1 Hartlepool          E06000001          Hartlepool … E02002483                 
## 2 Hartlepool          E06000001          Hartlepool … E02002484                 
## 3 Hartlepool          E06000001          Hartlepool … E02002485                 
## 4 Hartlepool          E06000001          Hartlepool … E02002487                 
## 5 Hartlepool          E06000001          Hartlepool … E02002488                 
## 6 Hartlepool          E06000001          Hartlepool … E02002489                 
## # … with 5 more variables: Number of consuming meters <dbl>,
## #   Consumption (kWh) <dbl>, Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>,
## #   Number of non consuming meters <chr>
msoa_gasData$MSOA11CD <- msoa_gasData$ 'Middle Layer Super Output Area (MSOA) Code' 
msoa_merged_sf_domgas <-merge(msoa_sf_data, msoa_gasData)
ggplot2::ggplot(msoa_merged_sf_domgas) + 
  geom_sf(aes(fill = `Mean consumption (kWh per meter)`)) +
  scale_fill_continuous(name = "Gas: Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all MSOAs)")

#mapping it

Does this match to non-gas areas??

2.2 Mapping Commercial

2.2.1 Mapping Electricty

# electricity consumption data for industry at MSOA level (pre downloaded)
inFile <-paste0(dataFolder, "energy/MSOA_NONDOM_2019.csv")
msoa_elecDatanondom <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `MSOA Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `Number of meters` = col_double(),
##   `Consumption (kWh)` = col_double(),
##   `Mean consumption (kWh per meter)` = col_double(),
##   `Median consumption (kWh per meter)` = col_double()
## )
head(msoa_elecDatanondom)
## # A tibble: 6 x 8
##   `Local Authority N… `Local Authority … `MSOA Name`  `Middle Layer Super Outpu…
##   <chr>               <chr>              <chr>        <chr>                     
## 1 Hartlepool          E06000001          Hartlepool … E02002483                 
## 2 Hartlepool          E06000001          Hartlepool … E02002484                 
## 3 Hartlepool          E06000001          Hartlepool … E02002485                 
## 4 Hartlepool          E06000001          Hartlepool … E02002487                 
## 5 Hartlepool          E06000001          Hartlepool … E02002488                 
## 6 Hartlepool          E06000001          Hartlepool … E02002489                 
## # … with 4 more variables: Number of meters <dbl>, Consumption (kWh) <dbl>,
## #   Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>
msoa_elecDatanondom$MSOA11CD <- msoa_elecDatanondom$ 'Middle Layer Super Output Area (MSOA) Code' 
msoa_merged_sf_nondom <-merge(msoa_sf_data, msoa_elecDatanondom)
ggplot2::ggplot(msoa_merged_sf_nondom) + 
  geom_sf(aes(fill = `Mean consumption (kWh per meter)`)) +
  scale_fill_continuous(name = "Electricity: Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all MSOAs)")

#mapping it

2.2.2 Mapping Gas

# gas consumption data for industry at MSOA level (pre downloaded)
inFile <-paste0(dataFolder, "energy/MSOA_NonDom_Gas_2019.csv")
msoa_gasDatanondom <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `MSOA Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `Number of meters` = col_double(),
##   `Consumption (kWh)` = col_double(),
##   `Mean consumption (kWh per meter)` = col_double(),
##   `Median consumption (kWh per meter)` = col_double()
## )
head(msoa_gasDatanondom)
## # A tibble: 6 x 8
##   `Local Authority N… `Local Authority … `MSOA Name`  `Middle Layer Super Outpu…
##   <chr>               <chr>              <chr>        <chr>                     
## 1 Hartlepool          E06000001          Hartlepool … E02002483                 
## 2 Hartlepool          E06000001          Hartlepool … E02002484                 
## 3 Hartlepool          E06000001          Hartlepool … E02002485                 
## 4 Hartlepool          E06000001          Hartlepool … E02002487                 
## 5 Hartlepool          E06000001          Hartlepool … E02002488                 
## 6 Hartlepool          E06000001          Hartlepool … E02002489                 
## # … with 4 more variables: Number of meters <dbl>, Consumption (kWh) <dbl>,
## #   Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>
msoa_gasDatanondom$MSOA11CD <- msoa_gasDatanondom$ 'Middle Layer Super Output Area (MSOA) Code' 
msoa_merged_sf_nondom_gas <-merge(msoa_sf_data, msoa_gasDatanondom)
ggplot2::ggplot(msoa_merged_sf_nondom_gas) + 
  geom_sf(aes(fill = `Mean consumption (kWh per meter)`)) +
  scale_fill_continuous(name = "Gas: Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all MSOAs)")

#mapping it

The holes tell you where there is no non-domestic gas use

3 Mapping the Lower Layer Super Output Area (LSOA)

3.1 Mapping Domestic

3.1.1 Mapping Electricity consumption

#Electricty consumption data LSOA pre downloaded
inFile <-paste0(dataFolder, "energy/LSOA_ELEC_2019.csv")
lsoa_elecData <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `Lower Layer Super Output Area (LSOA) Name` = col_character(),
##   `Lower Layer Super Output Area (LSOA) Code` = col_character(),
##   `Total number of domestic electricity meters` = col_double(),
##   `Total domestic electricity consumption (kWh)` = col_double(),
##   `Mean domestic electricity consumption 
## (kWh per meter)` = col_double(),
##   `Median domestic electricity consumption 
## (kWh per meter)` = col_double()
## )
lsoa_elecData$LSOA11CD <- lsoa_elecData$`Lower Layer Super Output Area (LSOA) Code`
head(msoa_elecData)
## # A tibble: 6 x 9
##   `Local Authority N… `Local Authority … `MSOA Name`  `Middle Layer Super Outpu…
##   <chr>               <chr>              <chr>        <chr>                     
## 1 Hartlepool          E06000001          Hartlepool … E02002483                 
## 2 Hartlepool          E06000001          Hartlepool … E02002484                 
## 3 Hartlepool          E06000001          Hartlepool … E02002485                 
## 4 Hartlepool          E06000001          Hartlepool … E02002487                 
## 5 Hartlepool          E06000001          Hartlepool … E02002488                 
## 6 Hartlepool          E06000001          Hartlepool … E02002489                 
## # … with 5 more variables: Number of meters <dbl>, Consumption (kWh) <dbl>,
## #   Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>, MSOA11CD <chr>
#The LSOA boundaries for the Solent have been pre-downloaded
inf<-paste0(dataFolder, "boundaries/LSOA/lsoa_solent.shp")
message ("Loading LSOA boundaries from file")
## Loading LSOA boundaries from file
lsoa_sf_data <- sf::read_sf(inf)
head(lsoa_sf_data)
## Simple feature collection with 6 features and 15 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 465991.4 ymin: 100849 xmax: 467770.5 ymax: 102360.8
## Projected CRS: OSGB 1936 / British National Grid
## # A tibble: 6 x 16
##   LSOA11CD  OBJECTID LSOA11NM   LSOA11NMW    BNG_E  BNG_N  LONG   LAT Shape__Are
##   <chr>        <int> <chr>      <chr>        <int>  <int> <dbl> <dbl>      <dbl>
## 1 E01017013    16519 Portsmout… Portsmouth… 466127 101741 -1.06  50.8    145134.
## 2 E01017014    16520 Portsmout… Portsmouth… 466924 101957 -1.05  50.8    757371.
## 3 E01017015    16521 Portsmout… Portsmouth… 467084 101499 -1.05  50.8    472647.
## 4 E01017016    16522 Portsmout… Portsmouth… 466330 101597 -1.06  50.8    122927.
## 5 E01017017    16523 Portsmout… Portsmouth… 466813 101069 -1.05  50.8    166924.
## 6 E01017018    16524 Portsmout… Portsmouth… 466350 101184 -1.06  50.8    184945.
## # … with 7 more variables: Shape__Len <dbl>, MSOA11CD <chr>, MSOA11NM <chr>,
## #   LAD11CD <chr>, LAD11NM <chr>, nLSOAs <int>, geometry <MULTIPOLYGON [m]>
table(lsoa_sf_data$LAD11NM)#How many LSOAs are there in each LA
## 
## Basingstoke and Deane        East Hampshire             Eastleigh 
##                   109                    72                    77 
##               Fareham               Gosport                  Hart 
##                    73                    53                    57 
##                Havant         Isle of Wight            New Forest 
##                    78                    89                   114 
##            Portsmouth           Southampton           Test Valley 
##                   125                   148                    71 
##            Winchester 
##                    70
lsoa_merged_sf <- merge(lsoa_sf_data, lsoa_elecData) #merging the boundaries and energy data
ggplot2::ggplot(lsoa_merged_sf) + 
  geom_sf(aes(fill = `Mean domestic electricity consumption \n(kWh per meter)`)) +
  scale_fill_continuous(name = "Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all LSOAs)")

#Mapping it

3.1.1.1 Looking at cities in more detail

#Cities such as Southampton disappear due to their density, we will now map Southampton alone to see this area in more detail
mapData <- dplyr::filter(lsoa_merged_sf, LAD11NM == "Southampton")

# plotting the electricity consumption of Southampton in more detail
ggplot2::ggplot(mapData) + 
  geom_sf(aes(fill = `Mean domestic electricity consumption \n(kWh per meter)`)) +
  scale_fill_continuous(name = "Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Southampton")

3.1.2 Mapping Gas

#Electricty consumption data LSOA pre downloaded
inFile <-paste0(dataFolder, "energy/LSOA_GAS_2019.csv")
lsoa_gasData <- readr::read_csv(inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `Local Authority Name` = col_character(),
##   `Local Authority Code` = col_character(),
##   `MSOA Name` = col_character(),
##   `Middle Layer Super Output Area (MSOA) Code` = col_character(),
##   `LSOA Name` = col_character(),
##   `Lower Layer Super Output Area (LSOA) Code` = col_character(),
##   `Number of consuming meters` = col_double(),
##   `Consumption (kWh)` = col_double(),
##   `Mean consumption (kWh per meter)` = col_double(),
##   `Median consumption (kWh per meter)` = col_double(),
##   `Number of non-consuming meters` = col_character()
## )
lsoa_gasData$LSOA11CD <- lsoa_gasData$`Lower Layer Super Output Area (LSOA) Code`
head(lsoa_gasData)
## # A tibble: 6 x 12
##   `Local Authority… `Local Authority… `MSOA Name` `Middle Layer Sup… `LSOA Name`
##   <chr>             <chr>             <chr>       <chr>              <chr>      
## 1 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## 2 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## 3 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## 4 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## 5 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## 6 Hartlepool        E06000001         Hartlepool… E02002483          Hartlepool…
## # … with 7 more variables: Lower Layer Super Output Area (LSOA) Code <chr>,
## #   Number of consuming meters <dbl>, Consumption (kWh) <dbl>,
## #   Mean consumption (kWh per meter) <dbl>,
## #   Median consumption (kWh per meter) <dbl>,
## #   Number of non-consuming meters <chr>, LSOA11CD <chr>
lsoa_merged_sf_gas <- merge(lsoa_sf_data, lsoa_gasData) #merging the boundaries and energy data
ggplot2::ggplot(lsoa_merged_sf_gas) + 
  geom_sf(aes(fill = `Mean consumption (kWh per meter)`)) +
  scale_fill_continuous(name = "Gas: Mean kWh per meter", low = "green", high = "red") +
  labs(caption = "Solent (all LSOAs)")

#Mapping it

Aha - this one shows where there is no gas :-)

3.1.3 Mapping the Indices of Multiple Deprivation

# Multiple deprivation data at MSOA pre downloaded
inFile <-paste0(dataFolder, "Indices of Multiple Deprivation/Indices_of_Multiple_Deprivation_(IMD)_2019.csv")
lsoa_multidep <- readr::read_csv (inFile)
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   .default = col_double(),
##   lsoa11cd = col_character(),
##   lsoa11nm = col_character(),
##   lsoa11nmw = col_character(),
##   LSOA01NM = col_character(),
##   LADcd = col_character(),
##   LADnm = col_character()
## )
## ℹ Use `spec()` for the full column specifications.
head(lsoa_multidep)
## # A tibble: 6 x 66
##     FID lsoa11cd  lsoa11nm  lsoa11nmw  st_areasha st_lengths IMD_Rank IMD_Decile
##   <dbl> <chr>     <chr>     <chr>           <dbl>      <dbl>    <dbl>      <dbl>
## 1     1 E01000816 Bromley … Bromley 0…    299021.      3337.    19874          7
## 2     2 E01000818 Bromley … Bromley 0…   1292309.      7408.    20548          7
## 3     3 E01000819 Bromley … Bromley 0…    397713.      4384.     9866          4
## 4     4 E01000820 Bromley … Bromley 0…    587458.      4838.    13461          5
## 5     5 E01000822 Bromley … Bromley 0…    218524.      2738.    20757          7
## 6     6 E01000823 Bromley … Bromley 0…    242692.      3195.    22675          7
## # … with 58 more variables: LSOA01NM <chr>, LADcd <chr>, LADnm <chr>,
## #   IMDScore <dbl>, IMDRank0 <dbl>, IMDDec0 <dbl>, IncScore <dbl>,
## #   IncRank <dbl>, IncDec <dbl>, EmpScore <dbl>, EmpRank <dbl>, EmpDec <dbl>,
## #   EduScore <dbl>, EduRank <dbl>, EduDec <dbl>, HDDScore <dbl>, HDDRank <dbl>,
## #   HDDDec <dbl>, CriScore <dbl>, CriRank <dbl>, CriDec <dbl>, BHSScore <dbl>,
## #   BHSRank <dbl>, BHSDec <dbl>, EnvScore <dbl>, EnvRank <dbl>, EnvDec <dbl>,
## #   IDCScore <dbl>, IDCRank <dbl>, IDCDec <dbl>, IDOScore <dbl>, IDORank <dbl>,
## #   IDODec <dbl>, CYPScore <dbl>, CYPRank <dbl>, CYPDec <dbl>, ASScore <dbl>,
## #   ASRank <dbl>, ASDec <dbl>, GBScore <dbl>, GBRank <dbl>, GBDec <dbl>,
## #   WBScore <dbl>, WBRank <dbl>, WBDec <dbl>, IndScore <dbl>, IndRank <dbl>,
## #   IndDec <dbl>, OutScore <dbl>, OutRank <dbl>, OutDec <dbl>, TotPop <dbl>,
## #   DepChi <dbl>, Pop16_59 <dbl>, Pop60_ <dbl>, WorkPop <dbl>,
## #   Shape__Area <dbl>, Shape__Length <dbl>
lsoa_multidep$LSOA11CD <- lsoa_multidep$lsoa11cd #creating a variable with the LSOA code in the same name as in sf_data
head(lsoa_multidep)
## # A tibble: 6 x 67
##     FID lsoa11cd  lsoa11nm  lsoa11nmw  st_areasha st_lengths IMD_Rank IMD_Decile
##   <dbl> <chr>     <chr>     <chr>           <dbl>      <dbl>    <dbl>      <dbl>
## 1     1 E01000816 Bromley … Bromley 0…    299021.      3337.    19874          7
## 2     2 E01000818 Bromley … Bromley 0…   1292309.      7408.    20548          7
## 3     3 E01000819 Bromley … Bromley 0…    397713.      4384.     9866          4
## 4     4 E01000820 Bromley … Bromley 0…    587458.      4838.    13461          5
## 5     5 E01000822 Bromley … Bromley 0…    218524.      2738.    20757          7
## 6     6 E01000823 Bromley … Bromley 0…    242692.      3195.    22675          7
## # … with 59 more variables: LSOA01NM <chr>, LADcd <chr>, LADnm <chr>,
## #   IMDScore <dbl>, IMDRank0 <dbl>, IMDDec0 <dbl>, IncScore <dbl>,
## #   IncRank <dbl>, IncDec <dbl>, EmpScore <dbl>, EmpRank <dbl>, EmpDec <dbl>,
## #   EduScore <dbl>, EduRank <dbl>, EduDec <dbl>, HDDScore <dbl>, HDDRank <dbl>,
## #   HDDDec <dbl>, CriScore <dbl>, CriRank <dbl>, CriDec <dbl>, BHSScore <dbl>,
## #   BHSRank <dbl>, BHSDec <dbl>, EnvScore <dbl>, EnvRank <dbl>, EnvDec <dbl>,
## #   IDCScore <dbl>, IDCRank <dbl>, IDCDec <dbl>, IDOScore <dbl>, IDORank <dbl>,
## #   IDODec <dbl>, CYPScore <dbl>, CYPRank <dbl>, CYPDec <dbl>, ASScore <dbl>,
## #   ASRank <dbl>, ASDec <dbl>, GBScore <dbl>, GBRank <dbl>, GBDec <dbl>,
## #   WBScore <dbl>, WBRank <dbl>, WBDec <dbl>, IndScore <dbl>, IndRank <dbl>,
## #   IndDec <dbl>, OutScore <dbl>, OutRank <dbl>, OutDec <dbl>, TotPop <dbl>,
## #   DepChi <dbl>, Pop16_59 <dbl>, Pop60_ <dbl>, WorkPop <dbl>,
## #   Shape__Area <dbl>, Shape__Length <dbl>, LSOA11CD <chr>
lsoa_multidep_merged_sf <- merge(lsoa_sf_data, lsoa_multidep) #merging these
ggplot2::ggplot(lsoa_multidep_merged_sf) +
  geom_sf(aes(fill=`IMDScore`))+ # which data set has the scores?
  scale_fill_continuous(name="IMD Score", low="green",high="red")+
  labs(caption ="Solent (all MSOAs)")

3.1.4 Mapping Fuel Poverty

3.1.4.1 2021 Fuel Poverty

inFile<-paste0(dataFolder, "Fuel Poverty/2021 LSOA_Fuel_Poverty.csv")
lsoa_fuelpov_2021<-readr::read_csv (inFile)
## Warning: Missing column names filled in: 'X9' [9]
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   `LSOA Code` = col_character(),
##   `LSOA Name` = col_character(),
##   `LA Code` = col_character(),
##   `LA Name` = col_character(),
##   Region = col_character(),
##   `Number of households1` = col_number(),
##   `Number of households in fuel poverty1` = col_double(),
##   `Proportion of households fuel poor (%)` = col_double(),
##   X9 = col_logical()
## )
## Warning: 1 parsing failure.
##   row                                    col expected  actual                                                                                                                                         file
## 32845 Proportion of households fuel poor (%) a double England '/Users/ben/University of Southampton/HCC Energy Landscape Mapping project - Documents/General/data/Fuel Poverty/2021 LSOA_Fuel_Poverty.csv'
head(lsoa_fuelpov_2021)
## # A tibble: 6 x 9
##   `LSOA Code` `LSOA Name`      `LA Code` `LA Name`     Region `Number of househ…
##   <chr>       <chr>            <chr>     <chr>         <chr>               <dbl>
## 1 E01000001   City of London … E09000001 City of Lond… London                928
## 2 E01000002   City of London … E09000001 City of Lond… London                882
## 3 E01000003   City of London … E09000001 City of Lond… London                878
## 4 E01000005   City of London … E09000001 City of Lond… London                502
## 5 E01000006   Barking and Dag… E09000002 Barking and … London                587
## 6 E01000007   Barking and Dag… E09000002 Barking and … London                646
## # … with 3 more variables: Number of households in fuel poverty1 <dbl>,
## #   Proportion of households fuel poor (%) <dbl>, X9 <lgl>
lsoa_fuelpov_2021$LSOA11CD <- lsoa_fuelpov_2021$"LSOA Code" #creating a variable with the LSOA code in the same name as in sf_data
lsoa_fuelpov_2021_merged <- merge(lsoa_sf_data, lsoa_fuelpov_2021) #merging these
# as above - why does it load as a char?
lsoa_fuelpov_2021_merged$pcFP <- as.numeric(lsoa_fuelpov_2021_merged$`Proportion of households fuel poor (%)`)
ggplot2::ggplot(lsoa_fuelpov_2021_merged) +
  geom_sf(aes(fill=pcFP))+ 
  scale_fill_continuous(name="Proportion of households fuel poor (%)", low="green",high="red")+
  labs(caption ="Solent (all LSOAs)")

4 The end

R.Version()
## $platform
## [1] "x86_64-apple-darwin17.0"
## 
## $arch
## [1] "x86_64"
## 
## $os
## [1] "darwin17.0"
## 
## $system
## [1] "x86_64, darwin17.0"
## 
## $status
## [1] ""
## 
## $major
## [1] "4"
## 
## $minor
## [1] "0.2"
## 
## $year
## [1] "2020"
## 
## $month
## [1] "06"
## 
## $day
## [1] "22"
## 
## $`svn rev`
## [1] "78730"
## 
## $language
## [1] "R"
## 
## $version.string
## [1] "R version 4.0.2 (2020-06-22)"
## 
## $nickname
## [1] "Taking Off Again"